Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

command-line-usage

Package Overview
Dependencies
Maintainers
1
Versions
51
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

command-line-usage

Generates command-line usage information

  • 6.1.3
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created

What is command-line-usage?

The command-line-usage npm package is used to generate usage guides for command-line applications. It helps in creating structured and styled help text that can be displayed when users need assistance with the command-line interface (CLI) of your application.

What are command-line-usage's main functionalities?

Defining Sections

This feature allows you to define different sections of the usage guide, such as headers and options. The code sample demonstrates how to create a usage guide with a description and options.

const commandLineUsage = require('command-line-usage');

const sections = [
  {
    header: 'My App',
    content: 'This is a description of my app.'
  },
  {
    header: 'Options',
    optionList: [
      {
        name: 'help',
        typeLabel: '{underline boolean}',
        description: 'Display this usage guide.'
      },
      {
        name: 'src',
        typeLabel: '{underline file}',
        description: 'The input file to process.'
      }
    ]
  }
];

const usage = commandLineUsage(sections);
console.log(usage);

Customizing Option Descriptions

This feature allows you to customize the descriptions of the options in your CLI application. The code sample shows how to define options with aliases and types, along with their descriptions.

const commandLineUsage = require('command-line-usage');

const sections = [
  {
    header: 'Options',
    optionList: [
      {
        name: 'verbose',
        alias: 'v',
        type: Boolean,
        description: 'Enable verbose mode.'
      },
      {
        name: 'timeout',
        alias: 't',
        type: Number,
        description: 'Set the timeout value in ms.'
      }
    ]
  }
];

const usage = commandLineUsage(sections);
console.log(usage);

Adding Examples

This feature allows you to add examples to your usage guide, making it easier for users to understand how to use your CLI application. The code sample demonstrates how to add concise and detailed examples.

const commandLineUsage = require('command-line-usage');

const sections = [
  {
    header: 'Examples',
    content: [
      {
        desc: '1. A concise example.',
        example: '$ app -v'
      },
      {
        desc: '2. A long example.',
        example: '$ app --timeout 1000'
      }
    ]
  }
];

const usage = commandLineUsage(sections);
console.log(usage);

Other packages similar to command-line-usage

Keywords

FAQs

Package last updated on 13 Apr 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc